home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 14 / CU Amiga Magazine's Super CD-ROM 14 (1997)(EMAP Images)(GB)(Track 1 of 3)[!][issue 1997-09].iso / CUCD / Programming / IEditor / Generators / E / gadgets.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-06-17  |  20.7 KB  |  686 lines

  1. /// Includes
  2. #define INTUI_V36_NAMES_ONLY
  3.  
  4. #include <exec/types.h>                 // exec
  5. #include <exec/lists.h>
  6. #include <exec/nodes.h>
  7. #include <dos/dos.h>                    // dos
  8. #include <dos/dostags.h>
  9. #include <intuition/intuition.h>        // intuition
  10. #include <intuition/gadgetclass.h>
  11. #include <libraries/gadtools.h>         // libraries
  12. #include <clib/exec_protos.h>           // protos
  13. #include <clib/dos_protos.h>
  14. #include <clib/intuition_protos.h>
  15. #include <pragmas/exec_pragmas.h>       // pragmas
  16. #include <pragmas/dos_pragmas.h>
  17. #include <pragmas/intuition_pragmas.h>
  18. #include <pragmas/gadtools_pragmas.h>
  19.  
  20. #include <string.h>
  21. #include <stdio.h>
  22. #include <stdlib.h>
  23. #include <ctype.h>
  24.  
  25. #include "DEV_IE:Generators/defs.h"
  26. #include "DEV_IE:Include/IEditor.h"
  27.  
  28. #include "Protos.h"
  29. ///
  30. /// Data
  31. static UWORD stringjusts[] = {
  32.     GACT_STRINGLEFT, GACT_STRINGRIGHT, GACT_STRINGCENTER
  33. };
  34.  
  35. static ULONG gadget_flags[] = { 1, 2, 4, 8, 16, 0 };
  36.  
  37. static UBYTE *GadKinds[] = {
  38.     "BUTTON_KIND",
  39.     "CHECKBOX_KIND",
  40.     "INTEGER_KIND",
  41.     "LISTVIEW_KIND",
  42.     "MX_KIND",
  43.     "NUMBER_KIND",
  44.     "CYCLE_KIND",
  45.     "PALETTE_KIND",
  46.     "SCROLLER_KIND",
  47.     NULL,
  48.     "SLIDER_KIND",
  49.     "STRING_KIND",
  50.     "TEXT_KIND"
  51. };
  52.  
  53. static UBYTE  *GadFlags[] = {
  54.     "PLACETEXT_LEFT",
  55.     "PLACETEXT_RIGHT",
  56.     "PLACETEXT_ABOVE",
  57.     "PLACETEXT_BELOW",
  58.     "PLACETEXT_IN"
  59. };
  60.  
  61. static UBYTE  *STRINGA_txts[] = {
  62.     NULL,
  63.     "GACT_STRINGRIGHT",
  64.     "GACT_STRINGCENTER"
  65. };
  66.  
  67. static UBYTE  *GTJ_txts[] = {
  68.     NULL,
  69.     "GTJ_RIGHT",
  70.     "GTJ_CENTER"
  71. };
  72.  
  73. static UBYTE   GADisabled[]         = "GA_DISABLED, TRUE, ";
  74. static UBYTE   GAImmediate[]        = "GA_IMMEDIATE, TRUE, ";
  75. static UBYTE   GATabCycle[]         = "GA_TABCYCLE, FALSE, ";
  76. static UBYTE   GARelVerify[]        = "GA_RELVERIFY, TRUE, ";
  77. static UBYTE   STRINGAExitHelp[]    = "STRINGA_EXITHELP, TRUE, ";
  78. static UBYTE   STRINGAReplaceMode[] = "STRINGA_REPLACEMODE, TRUE, ";
  79. static UBYTE   PGAFreedom[]         = "PGA_FREEDOM, LORIENT_VERT, ";
  80. static UBYTE   LAYOUTASpacing[]     = "LAYOUTA_SPACING, %ld, ";
  81. ///
  82.  
  83.  
  84. /// WriteNewGadgets
  85. void WriteNewGadgets( struct GenFiles *Files, struct IE_Data *IE )
  86. {
  87.     struct WindowInfo  *wnd;
  88.     LONG                loc;
  89.  
  90.     for( wnd = IE->win_list.mlh_Head; wnd->wi_succ; wnd = wnd->wi_succ ) {
  91.     if( wnd->wi_NumGads - wnd->wi_NumBools ) {
  92.         TEXT    Label[60];
  93.  
  94.         StrToLower( wnd->wi_Label, Label );
  95.  
  96.         FPrintf( Files->Std, "\nDEF %sngad = [\n\t", Label );
  97.  
  98.         loc = IE->C_Prefs & SMART_STR;
  99.  
  100.         if( IE->SrcFlags & LOCALIZE )
  101.         loc = wnd->wi_Tags & W_LOC_GADGETS;
  102.  
  103.         WriteNewGads( Files, IE, &wnd->wi_Gadgets, loc );
  104.     }
  105.     }
  106.  
  107. }
  108. ///
  109. /// WriteGadgetTags
  110. void WriteGadgetTags( struct GenFiles *Files, struct IE_Data *IE )
  111. {
  112.     struct WindowInfo  *wnd;
  113.     ULONG               loc;
  114.  
  115.     for( wnd = IE->win_list.mlh_Head; wnd->wi_succ; wnd = wnd->wi_succ ) {
  116.     if( wnd->wi_NumGads - wnd->wi_NumBools ) {
  117.         TEXT    Label[60];
  118.  
  119.         StrToLower( wnd->wi_Label, Label );
  120.  
  121.         loc = IE->C_Prefs & SMART_STR;
  122.  
  123.         if( IE->SrcFlags & LOCALIZE )
  124.         loc = wnd->wi_Tags & W_LOC_GADGETS;
  125.  
  126.         FPrintf( Files->Std, "\nDEF %sgtags = [\n\t", Label );
  127.  
  128.         WriteTags( Files, IE, &wnd->wi_Gadgets, loc );
  129.     }
  130.     }
  131. }
  132. ///
  133. /// WriteBoolStruct
  134. void WriteBoolStruct( struct GenFiles *Files, struct IE_Data *IE )
  135. {
  136.     struct WindowInfo  *wnd;
  137.  
  138.     for( wnd = IE->win_list.mlh_Head; wnd->wi_succ; wnd = wnd->wi_succ )
  139.     if( wnd->wi_NumBools )
  140.         WriteBooleans( Files, IE, &wnd->wi_Gadgets, wnd );
  141. }
  142. ///
  143. /// WriteGadgetBanks
  144. void WriteGadgetBanks( struct GenFiles *Files, struct IE_Data *IE )
  145. {
  146.     struct WindowInfo  *wnd;
  147.  
  148.     for( wnd = IE->win_list.mlh_Head; wnd->wi_succ; wnd = wnd->wi_succ ) {
  149.     struct GadgetBank  *bank;
  150.     ULONG               loc;
  151.  
  152.     loc = IE->C_Prefs & SMART_STR;
  153.  
  154.     if( IE->SrcFlags & LOCALIZE )
  155.         loc = wnd->wi_Tags & W_LOC_GADGETS;
  156.  
  157.     for( bank = wnd->wi_GBanks.mlh_Head; bank->Node.ln_Succ; bank = bank->Node.ln_Succ ) {
  158.         ULONG               NotBool = 0;
  159.         struct GadgetInfo  *gad;
  160.  
  161.         for( gad = bank->Storage.mlh_Head; gad->g_Node.ln_Succ; gad = gad->g_Node.ln_Succ )
  162.         if( gad->g_Kind != BOOLEAN )
  163.             NotBool += 1;
  164.  
  165.         if( NotBool ) {
  166.         TEXT    Label[60];
  167.  
  168.         StrToLower( bank->Label, Label );
  169.  
  170.         FPrintf( Files->Std, "\nDEF %sgtypes = [\n\t", Label );
  171.  
  172.         WriteGTypes( Files, IE, &bank->Storage );
  173.  
  174.         WriteGLabels( Files, IE, &bank->Storage, wnd );
  175.  
  176.         FPrintf( Files->Std, "\nDEF %sngad = [\n\t", Label );
  177.  
  178.         WriteNewGads( Files, IE, &bank->Storage, loc );
  179.  
  180.         FPrintf( Files->Std, "\nDEF %sgtags = [\n\t", Label );
  181.  
  182.         WriteTags( Files, IE, &bank->Storage, loc );
  183.         }
  184.  
  185.         WriteBooleans( Files, IE, &bank->Storage, wnd );
  186.     }
  187.     }
  188. }
  189. ///
  190.  
  191. /// WriteNewGads
  192. void WriteNewGads( struct GenFiles *Files, struct IE_Data *IE, struct MinList *Gadgets, ULONG loc )
  193. {
  194.     struct GadgetInfo  *gad;
  195.     UBYTE               buffer[256], *or;
  196.     UWORD               c, c2;
  197.  
  198.     for( gad = Gadgets->mlh_Head; gad->g_Node.ln_Succ; gad = gad->g_Node.ln_Succ ) {
  199.     if( gad->g_Kind < BOOLEAN ) {
  200.         TEXT    Label[60];
  201.  
  202.         FPrintf( Files->Std, "%ld, %ld, %ld, %ld, ",
  203.              gad->g_Left - IE->ScreenData->XOffset,
  204.              gad->g_Top  - IE->ScreenData->YOffset,
  205.              gad->g_Width, gad->g_Height );
  206.  
  207.         if( gad->g_Titolo[0] ) {
  208.         if( loc )
  209.             FPrintf( Files->Std, "%s,", (FindString( &Files->Strings, gad->g_Titolo ))->Label );
  210.         else
  211.             FPrintf( Files->Std, "'%s',", gad->g_Titolo );
  212.         } else
  213.         FPuts( Files->Std, Null );
  214.  
  215.         if( gad->g_Font )
  216.         FPrintf( Files->Std, "{%s}", gad->g_Font->txa_Label );
  217.         else
  218.         FPuts( Files->Std, Null );
  219.  
  220.         StrToUpper( gad->g_Label, Label );
  221.  
  222.         FPrintf( Files->Std, ", GD_%s, ", Label );
  223.  
  224.         if( gad->g_Flags ) {
  225.  
  226.         buffer[0] = '\0';
  227.  
  228.         if( gad->g_Flags & 32 ) {
  229.             strcpy( buffer, "NG_HIGHLABEL" );
  230.             or = " OR ";
  231.         } else
  232.             or = "";
  233.  
  234.  
  235.         c = gad->g_Flags & 0xFFDF;
  236.         if( c ) {
  237.             strcat( buffer, or );
  238.  
  239.             c2 = 0;
  240.             while(!( c & gadget_flags[ c2 ]))
  241.             c2 += 1;
  242.  
  243.             strcat( buffer, GadFlags[ c2 ]);
  244.         }
  245.  
  246.         FPuts( Files->Std, buffer );
  247.         } else
  248.         FPuts( Files->Std, Null );
  249.  
  250.  
  251.         FPuts( Files->Std, ", NIL, " );
  252.  
  253.         if(( IE->C_Prefs & CLICKED ) && ( gad->g_Kind != TEXT_KIND ) && ( gad->g_Kind != NUMBER_KIND ))
  254.         FPrintf( Files->Std, "{%sclicked}", gad->g_Label );
  255.         else
  256.         FPuts( Files->Std, Null );
  257.  
  258.         FPuts( Files->Std, ",\n\t" );
  259.     }
  260.     }
  261.  
  262.     Flush( Files->Std );
  263.     Seek( Files->Std, -3, OFFSET_CURRENT );
  264.     FPuts( Files->Std, "\n]:newgadget\n" );
  265. }
  266. ///
  267. /// WriteTags
  268. void WriteTags( struct GenFiles *Files, struct IE_Data *IE, struct MinList *Gadgets, ULONG loc )
  269. {
  270.     struct GadgetInfo  *gad;
  271.  
  272.     for( gad = Gadgets->mlh_Head; gad->g_Node.ln_Succ; gad = gad->g_Node.ln_Succ ) {
  273.     if( gad->g_Kind < BOOLEAN ) {
  274.  
  275.         if( gad->g_Tags & 1 )
  276.         FPuts( Files->Std, "GT_UNDERSCORE, \"_\", " );
  277.  
  278.         switch( gad->g_Kind ) {
  279.  
  280.         case BUTTON_KIND:
  281.             if( gad->g_Tags & 2 )
  282.             FPuts( Files->Std, GADisabled );
  283.             if( gad->g_Tags & 4 )
  284.             FPuts( Files->Std, GAImmediate );
  285.             break;
  286.  
  287.         case CHECKBOX_KIND:
  288.             if( gad->g_Tags & 2 )
  289.             FPuts( Files->Std, GADisabled );
  290.             if( gad->g_Tags & 4 )
  291.             FPuts( Files->Std, "GTCB_CHECKED, TRUE, " );
  292.             if( gad->g_Tags & 8 )
  293.             FPuts( Files->Std, "GTCB_SCALED, TRUE, " );
  294.             break;
  295.  
  296.         case INTEGER_KIND:
  297.             if( ((struct IK)(gad->g_Data)).Num )
  298.             FPrintf( Files->Std, "GTIN_NUMBER, %ld, ", ((struct IK)(gad->g_Data)).Num );
  299.             if( ((struct IK)(gad->g_Data)).MaxC != 10 )
  300.             FPrintf( Files->Std, "GTIN_MAXCHARS, %ld, ", ((struct IK)(gad->g_Data)).MaxC );
  301.             if( ((struct IK)(gad->g_Data)).Just )
  302.             FPrintf( Files->Std, "STRINGA_JUSTIFICATION, %s, ", STRINGA_txts[ ((struct IK)(gad->g_Data)).Just ]);
  303.             if( gad->g_Tags & 2 )
  304.             FPuts( Files->Std, GADisabled );
  305.             if( gad->g_Tags & 4 )
  306.             FPuts( Files->Std, GAImmediate );
  307.             if(!( gad->g_Tags & 8 ))
  308.             FPuts( Files->Std, GATabCycle );
  309.             if( gad->g_Tags & 0x10 )
  310.             FPuts( Files->Std, STRINGAExitHelp );
  311.             if( gad->g_Tags & 0x20 )
  312.             FPuts( Files->Std, STRINGAReplaceMode );
  313.             break;
  314.  
  315.         case LISTVIEW_KIND:
  316.             if( gad->g_NumScelte )
  317.             FPrintf( Files->Std, "GTLV_LABELS, {%slist}, ", gad->g_Label );
  318.             if( ((struct LK)(gad->g_Data)).Top )
  319.             FPrintf( Files->Std, "GTLV_TOP, %ld, ", ((struct LK)(gad->g_Data)).Top );
  320.             if( ((struct LK)(gad->g_Data)).Vis )
  321.             FPrintf( Files->Std, "GTLV_MAKEVISIBLE, %ld, ", ((struct LK)(gad->g_Data)).Vis );
  322.             if( ((struct LK)(gad->g_Data)).ScW != 16 )
  323.             FPrintf( Files->Std, "GTLV_SCROLLWIDTH, %ld, ", ((struct LK)(gad->g_Data)).ScW );
  324.             if( ((struct LK)(gad->g_Data)).Sel )
  325.             FPrintf( Files->Std, "GTLV_SELECTED, %ld, ", ((struct LK)(gad->g_Data)).Sel );
  326.             if( ((struct LK)(gad->g_Data)).Spc )
  327.             FPrintf( Files->Std, LAYOUTASpacing, ((struct LK)(gad->g_Data)).Spc );
  328.             if( ((struct LK)(gad->g_Data)).IH )
  329.             FPrintf( Files->Std, "GTLV_ITEMHEIGHT, %ld, ", ((struct LK)(gad->g_Data)).IH );
  330.             if( ((struct LK)(gad->g_Data)).MaxP )
  331.             FPrintf( Files->Std, "GTLV_MAXPEN, %ld, ", ((struct LK)(gad->g_Data)).MaxP );
  332.             if( gad->g_Tags & 2 )
  333.             FPuts( Files->Std, GADisabled );
  334.             if( gad->g_Tags & 4 )
  335.             FPuts( Files->Std, "GTLV_READONLY, TRUE, " );
  336.             if( gad->g_Tags & 8 )
  337.             FPuts( Files->Std, "GTLV_SHOWSELECTED, NIL, " );
  338.             break;
  339.  
  340.         case MX_KIND:
  341.             FPuts( Files->Std, "GTMX_LABLES, {" );
  342.             if( loc )
  343.             FPrintf( Files->Std, "%s", (FindArray( &Files->Arrays, &gad->g_Scelte ))->Label );
  344.             else
  345.             FPrintf( Files->Std, "%slabels", gad->g_Label );
  346.             FPuts( Files->Std, "}, " );
  347.             if( ((struct MK)(gad->g_Data)).Act )
  348.             FPrintf( Files->Std, "GTMX_ACTIVE, %ld, ", ((struct MK)(gad->g_Data)).Act );
  349.             if( ((struct MK)(gad->g_Data)).Spc != 1 )
  350.             FPrintf( Files->Std, "GTMX_SPACING, %ld, ", ((struct MK)(gad->g_Data)).Spc );
  351.             if( gad->g_Titolo[0] )
  352.             FPrintf( Files->Std, "GTMX_TITLEPLACE, %s, ", GadFlags[ ((struct MK)(gad->g_Data)).TitPlc ]);
  353.             if( gad->g_Tags & 2 )
  354.             FPuts( Files->Std, GADisabled );
  355.             if( gad->g_Tags & 4 )
  356.             FPuts( Files->Std, "GTMX_SCALED, TRUE, " );
  357.             break;
  358.  
  359.         case NUMBER_KIND:
  360.             if( ((struct NK)(gad->g_Data)).Num )
  361.             FPrintf( Files->Std, "GTNM_NUMBER), %ld, ", ((struct NK)(gad->g_Data)).Num );
  362.             if( ((struct NK)(gad->g_Data)).FPen != -1 )
  363.             FPrintf( Files->Std, "GTNM_FRONTPEN, %ld, ", ((struct NK)(gad->g_Data)).FPen );
  364.             if( ((struct NK)(gad->g_Data)).BPen != -1 )
  365.             FPrintf( Files->Std, "GTNM_BACKPEN, %ld, ", ((struct NK)(gad->g_Data)).BPen );
  366.             if( ((struct NK)(gad->g_Data)).Just )
  367.             FPrintf( Files->Std, "GTNM_JUSTIFICATION, %s, ", GTJ_txts[ ((struct NK)(gad->g_Data)).Just ]);
  368.             if( ((struct NK)(gad->g_Data)).MNL != 10 )
  369.             FPrintf( Files->Std, "GTNM_MAXNUMBERLEN, %ld, ", ((struct NK)(gad->g_Data)).MNL );
  370.             if( strcmp( ((struct NK)(gad->g_Data)).Format, "%ld" )) {
  371.             FPuts( Files->Std, "GTNM_FORMAT, " );
  372.             if( loc )
  373.                 FPrintf( Files->Std, "%s, ", (FindString( &Files->Strings, ((struct NK)(gad->g_Data)).Format ))->Label );
  374.             else
  375.                 FPrintf( Files->Std, "'%s', ", ((struct NK)(gad->g_Data)).Format );
  376.             }
  377.             if( gad->g_Tags & 2 )
  378.             FPuts( Files->Std, "GTNM_BORDER, TRUE, " );
  379.             if( gad->g_Tags & 4 )
  380.             FPuts( Files->Std, "GTNM_CLIPPED, TRUE, " );
  381.             break;
  382.  
  383.         case CYCLE_KIND:
  384.             FPuts( Files->Std, "GTCY_LABELS, {" );
  385.             if( loc )
  386.             FPrintf( Files->Std, "%s", (FindArray( &Files->Arrays, &gad->g_Scelte ))->Label );
  387.             else
  388.             FPrintf( Files->Std, "%slabels", gad->g_Label );
  389.             FPuts( Files->Std, "}, " );
  390.             if( ((struct CK)(gad->g_Data)).Act )
  391.             FPrintf( Files->Std, "GTCY_ACTIVE, %ld, ", ((struct CK)(gad->g_Data)).Act );
  392.             if( gad->g_Tags & 2 )
  393.             FPuts( Files->Std, GADisabled );
  394.             break;
  395.  
  396.         case PALETTE_KIND:
  397.             if( ((struct PK)(gad->g_Data)).Depth != 1 )
  398.             FPrintf( Files->Std, "GTPA_DEPTH, %ld, ", ((struct PK)(gad->g_Data)).Depth );
  399.             if( ((struct PK)(gad->g_Data)).Color != 1 )
  400.             FPrintf( Files->Std, "GTPA_COLOR, %ld, ", ((struct PK)(gad->g_Data)).Color );
  401.             if( ((struct PK)(gad->g_Data)).ColOff )
  402.             FPrintf( Files->Std, "GTPA_COLOROFFSET, %ld, ", ((struct PK)(gad->g_Data)).ColOff );
  403.             if( ((struct PK)(gad->g_Data)).IW )
  404.             FPrintf( Files->Std, "GTPA_INDICATORWIDTH, %ld, ", ((struct PK)(gad->g_Data)).IW );
  405.             if( ((struct PK)(gad->g_Data)).IH )
  406.             FPrintf( Files->Std, "GTPA_INDICATORHEIGHT, %ld, ", ((struct PK)(gad->g_Data)).IH );
  407.             if(( ((struct PK)(gad->g_Data)).NumCol ) && ( ((struct PK)(gad->g_Data)).NumCol != 2 ))
  408.             FPrintf( Files->Std, "GTPA_NUMCOLORS, %ld, ", ((struct PK)(gad->g_Data)).NumCol );
  409.             if( gad->g_Tags & 2 )
  410.             FPuts( Files->Std, GADisabled );
  411.             break;
  412.  
  413.         case SCROLLER_KIND:
  414.             if( ((struct SK)(gad->g_Data)).Top )
  415.             FPrintf( Files->Std, "GTSC_TOP, %ld, ", ((struct SK)(gad->g_Data)).Top );
  416.             if( ((struct SK)(gad->g_Data)).Tot )
  417.             FPrintf( Files->Std, "GTSC_TOTAL, %ld, ", ((struct SK)(gad->g_Data)).Tot );
  418.             if( ((struct SK)(gad->g_Data)).Vis != 2 )
  419.             FPrintf( Files->Std, "GTSC_VISIBLE, %ld, ", ((struct SK)(gad->g_Data)).Vis );
  420.             if( ((struct SK)(gad->g_Data)).Arr )
  421.             FPrintf( Files->Std, "GTSC_ARROWS, %ld, ", ((struct SK)(gad->g_Data)).Arr );
  422.             if( ((struct SK)(gad->g_Data)).Free )
  423.             FPuts( Files->Std, PGAFreedom );
  424.             if( gad->g_Tags & 2 )
  425.             FPuts( Files->Std, GADisabled );
  426.             if( gad->g_Tags & 2 )
  427.             FPuts( Files->Std, GARelVerify );
  428.             if( gad->g_Tags & 8 )
  429.             FPuts( Files->Std, GAImmediate );
  430.             break;
  431.  
  432.         case SLIDER_KIND:
  433.             if( ((struct SlK)(gad->g_Data)).Min )
  434.             FPrintf( Files->Std, "GTSL_MIN, %ld, ", ((struct SlK)(gad->g_Data)).Min );
  435.             if( ((struct SlK)(gad->g_Data)).Max != 15 )
  436.             FPrintf( Files->Std, "GTSL_MAX, %ld, ", ((struct SlK)(gad->g_Data)).Max );
  437.             if( ((struct SlK)(gad->g_Data)).Level )
  438.             FPrintf( Files->Std, "GTSL_LEVEL, %ld, ", ((struct SlK)(gad->g_Data)).Level );
  439.             if( ((struct SlK)(gad->g_Data)).MLL != 2 )
  440.             FPrintf( Files->Std, "GTSL_MAXLEVELLEN, %ld, ", ((struct SlK)(gad->g_Data)).MLL );
  441.             FPrintf( Files->Std, "GTSL_LEVELPLACE, %s, ", GadFlags[ ((struct SlK)(gad->g_Data)).LevPlc ]);
  442.             if( ((struct SlK)(gad->g_Data)).Just )
  443.             FPrintf( Files->Std, "GTSL_JUSTIFICATION, %ld, ", GTJ_txts[ ((struct SlK)(gad->g_Data)).Just ]);
  444.             if( ((struct SlK)(gad->g_Data)).Free )
  445.             FPuts( Files->Std, PGAFreedom );
  446.             if( ((struct SlK)(gad->g_Data)).MPL )
  447.             FPrintf( Files->Std, "GTSL_MAXPIXELLEN, %ld, ", ((struct SlK)(gad->g_Data)).MPL );
  448.             FPuts( Files->Std, "GTSL_LEVELFORMAT, " );
  449.             if( loc )
  450.             FPrintf( Files->Std, "%s, ", (FindString( &Files->Strings, ((struct SlK)(gad->g_Data)).Format ))->Label );
  451.             else
  452.             FPrintf( Files->Std, "'%s', ", ((struct SlK)(gad->g_Data)).Format );
  453.             if( gad->g_Tags & 2 )
  454.             FPuts( Files->Std, GADisabled );
  455.             if( gad->g_Tags & 2 )
  456.             FPuts( Files->Std, GARelVerify );
  457.             if( gad->g_Tags & 8 )
  458.             FPuts( Files->Std, GAImmediate );
  459.             break;
  460.  
  461.         case STRING_KIND:
  462.             if( ((struct StK)(gad->g_Data)).MaxC )
  463.             FPrintf( Files->Std, "GTST_MAXCHARS, %ld, ", ((struct StK)(gad->g_Data)).MaxC );
  464.             if( ((struct StK)(gad->g_Data)).Just )
  465.             FPrintf( Files->Std, "STRINGA_JUSTIFICATION, %s, ", STRINGA_txts[ ((struct StK)(gad->g_Data)).Just ]);
  466.             if ( *((UBYTE *)(gad->g_ExtraMem)) ) {
  467.             FPuts( Files->Std, "GTST_STRING, " );
  468.             if( loc )
  469.                 FPrintf( Files->Std, "%s, ", (FindString( &Files->Strings, gad->g_ExtraMem ))->Label );
  470.             else
  471.                 FPrintf( Files->Std, "'%s', ", gad->g_ExtraMem );
  472.             }
  473.             if( gad->g_Tags & 2 )
  474.             FPuts( Files->Std, GADisabled );
  475.             if( gad->g_Tags & 4 )
  476.             FPuts( Files->Std, GAImmediate );
  477.             if(!( gad->g_Tags & 8 ))
  478.             FPuts( Files->Std, GATabCycle );
  479.             if( gad->g_Tags & 0x10 )
  480.             FPuts( Files->Std, STRINGAExitHelp );
  481.             if( gad->g_Tags & 0x20 )
  482.             FPuts( Files->Std, STRINGAReplaceMode );
  483.             break;
  484.  
  485.         case TEXT_KIND:
  486.             if( ((struct TK)(gad->g_Data)).FPen != -1 )
  487.             FPrintf( Files->Std, "GTTX_FRONTPEN, %ld, ", ((struct TK)(gad->g_Data)).FPen );
  488.             if( ((struct TK)(gad->g_Data)).BPen != -1 )
  489.             FPrintf( Files->Std, "GTTX_BACKPEN, %ld, ", ((struct TK)(gad->g_Data)).BPen );
  490.             if( ((struct TK)(gad->g_Data)).Just )
  491.             FPrintf( Files->Std, "GTTX_JUSTIFICATION, %s, ", GTJ_txts[ ((struct TK)(gad->g_Data)).Just ]);
  492.             if ( *((UBYTE *)(gad->g_ExtraMem)) ) {
  493.             FPuts( Files->Std, "GTTX_TEXT, " );
  494.             if( loc )
  495.                 FPrintf( Files->Std, "%s, ", (FindString( &Files->Strings, gad->g_ExtraMem ))->Label );
  496.             else
  497.                 FPrintf( Files->Std, "'%s', ", gad->g_ExtraMem );
  498.             }
  499.             if( gad->g_Tags & 2 )
  500.             FPuts( Files->Std, "GTTX_COPYTEXT, TRUE, " );
  501.             if( gad->g_Tags & 4 )
  502.             FPuts( Files->Std, "GTTX_BORDER, TRUE, " );
  503.             if( gad->g_Tags & 8 )
  504.             FPuts( Files->Std, "GTTX_CLIPPED, TRUE, " );
  505.             break;
  506.         }
  507.  
  508.         FPuts( Files->Std, "TAG_DONE,\n\t" );
  509.     }
  510.     }
  511.  
  512.     Flush( Files->Std );
  513.     Seek( Files->Std, -3, OFFSET_CURRENT );
  514.     FPuts( Files->Std, "\n]:LONG\n" );
  515. }
  516. ///
  517. /// WriteBooleans
  518. void WriteBooleans( struct GenFiles *Files, struct IE_Data *IE, struct MinList *Gadgets, struct WindowInfo *wnd )
  519. {
  520.     struct BooleanInfo *gad, *next;
  521.     struct ImageNode   *img;
  522.     LONG                loc;
  523.  
  524.     loc = IE->C_Prefs & SMART_STR;
  525.  
  526.     if( IE->SrcFlags & LOCALIZE )
  527.     loc = wnd->wi_Tags & W_LOC_GADGETS;
  528.  
  529.     for( gad = Gadgets->mlh_TailPred; gad->b_Node.ln_Pred; gad = gad->b_Node.ln_Pred ) {
  530.     if( gad->b_Kind == BOOLEAN ) {
  531.         TEXT    Label[60];
  532.  
  533.         StrToLower( gad->b_Label, Label );
  534.  
  535.         if(( gad->b_flags2 & B_TEXT ) && ( gad->b_Titolo[0] )) {
  536.  
  537.         FPrintf( Files->Std, "\nDEF %sitext = [\n", Label );
  538.  
  539.         FPrintf( Files->Std, "\t%ld, %ld, %ld,\n"
  540.                       "\t%ld, %ld,\n\t",
  541.               gad->b_FrontPen, gad->b_BackPen,
  542.               gad->b_DrawMode, gad->b_TxtLeft,
  543.               gad->b_TxtTop );
  544.  
  545.         if( gad->b_Font ) {
  546.             TEXT    Label[60];
  547.  
  548.             StrToLower( gad->b_Font->txa_Label, Label );
  549.             FPrintf( Files->Std, "{%s}", Label );
  550.         } else
  551.             FPuts( Files->Std, Null );
  552.  
  553.         FPuts( Files->Std, ",\n\t" );
  554.  
  555.         if( loc )
  556.             FPrintf( Files->Std, "%s", (FindString( &Files->Strings, gad->b_Titolo ))->Label );
  557.         else
  558.             FPrintf( Files->Std, "'%s'", gad->b_Titolo );
  559.         FPuts( Files->Std, ",\n\tNIL\n]:intuitext\n" );
  560.         }
  561.  
  562.         FPrintf( Files->Std, "DEF %sgadget = [", Label );
  563.  
  564.         next = gad->b_Node.ln_Succ;
  565.         if( next->b_Node.ln_Succ )
  566.         FPrintf( Files->Std, "{%sgadget}", next->b_Label );
  567.         else
  568.         FPuts( Files->Std, Null );
  569.  
  570.  
  571.         FPrintf( Files->Std, ",\n\t%ld, %ld, %ld, %ld,\n",
  572.              gad->b_Left - IE->ScreenData->XOffset,
  573.              gad->b_Top  - IE->ScreenData->YOffset,
  574.              gad->b_Width, gad->b_Height );
  575.  
  576.  
  577.         VFPrintf( Files->Std, "\t$%04x, $%04x, 1,\n", &gad->b_Flags );
  578.  
  579.  
  580.         if( img = gad->b_GadgetRender ) {
  581.         TEXT    Label[60];
  582.  
  583.         (ULONG)img -= sizeof( struct Node );
  584.  
  585.         StrToLower( img->in_Label, Label );
  586.         FPrintf( Files->Std, "\t{%simg}, ", Label );
  587.         } else
  588.         FPuts( Files->Std, "\tNIL, " );
  589.  
  590.  
  591.         if( img = gad->b_SelectRender ) {
  592.         TEXT    Label[60];
  593.  
  594.         (ULONG)img -= sizeof( struct Node );
  595.  
  596.         StrToLower( img->in_Label, Label );
  597.         FPrintf( Files->Std, "{%simg},\n", Label );
  598.         } else
  599.         FPuts( Files->Std, "NIL,\n" );
  600.  
  601.  
  602.         if(( gad->b_flags2 & B_TEXT ) && ( gad->b_Titolo[0] ))
  603.         FPrintf( Files->Std, "\t{%sitext}", Label );
  604.         else
  605.         FPuts( Files->Std, "\tNIL" );
  606.  
  607.         {
  608.         TEXT    Label[60];
  609.         StrToUpper( gad->b_Label, Label );
  610.         FPrintf( Files->Std, ",\n\t0, 0,\n\tGD_%s,\n\t", Label );
  611.         }
  612.  
  613.         if( IE->C_Prefs & CLICKED )
  614.         FPrintf( Files->Std, "{%sclicked}", gad->b_Label );
  615.         else
  616.         FPuts( Files->Std, Null );
  617.  
  618.         if( wnd->wi_IDCMP & IDCMP_GADGETHELP )
  619.         FPrintf( Files->Std, ",\n\t3,\n\t%ld, %ld, %ld, %ld",
  620.              gad->b_Left - IE->ScreenData->XOffset,
  621.              gad->b_Top  - IE->ScreenData->YOffset,
  622.              gad->b_Width, gad->b_Height );
  623.  
  624.         FPuts( Files->Std,
  625.            ( wnd->wi_IDCMP & IDCMP_GADGETHELP ) ? " ]:extgadget\n" : " ]:gadget\n" );
  626.     }
  627.     }
  628. }
  629. ///
  630. /// WriteGTypes
  631. void WriteGTypes( struct GenFiles *Files, struct IE_Data *IE, struct MinList *Gadgets )
  632. {
  633.     struct GadgetInfo  *gad;
  634.  
  635.     for( gad = Gadgets->mlh_Head; gad->g_Node.ln_Succ; gad = gad->g_Node.ln_Succ ) {
  636.     if( gad->g_Kind < BOOLEAN ) {
  637.         FPuts( Files->Std, GadKinds[ gad->g_Kind - 1 ]);
  638.         FPuts( Files->Std, ",\n\t" );
  639.     }
  640.     }
  641.  
  642.     FPuts( Files->Std, "NIL ]:INT\n" );
  643. }
  644. ///
  645. /// WriteGLabels
  646. void WriteGLabels( struct GenFiles *Files, struct IE_Data *IE, struct MinList *Gadgets, struct WindowInfo *Wnd )
  647. {
  648.     struct GadgetInfo  *gad;
  649.     ULONG               loc;
  650.  
  651.     loc = IE->C_Prefs & SMART_STR;
  652.  
  653.     if( IE->SrcFlags & LOCALIZE )
  654.     loc = Wnd->wi_Tags & W_LOC_GADGETS;
  655.  
  656.     for( gad = Gadgets->mlh_Head; gad->g_Node.ln_Succ; gad = gad->g_Node.ln_Succ ) {
  657.  
  658.     switch( gad->g_Kind ) {
  659.  
  660.         case LISTVIEW_KIND:
  661.         WriteList( Files, &gad->g_Scelte, gad->g_Label, gad->g_NumScelte, IE );
  662.         break;
  663.  
  664.         case MX_KIND:
  665.         case CYCLE_KIND:
  666.  
  667.         if(!( loc )) {
  668.             struct GadgetScelta    *gs;
  669.             TEXT                    Label[60];
  670.  
  671.             StrToLower( gad->g_Label, Label );
  672.  
  673.             FPrintf( Files->Std,  "\nDEF %slabels = [\n\t", Label );
  674.  
  675.             for( gs = gad->g_Scelte.mlh_Head; gs->gs_Node.ln_Succ; gs = gs->gs_Node.ln_Succ )
  676.             FPrintf( Files->Std, "'%s',\n\t", gs->gs_Testo );
  677.  
  678.             FPuts( Files->Std, "NIL\n]\n" );
  679.         }
  680.         break;
  681.     }
  682.     }
  683. }
  684. ///
  685.  
  686.